<?php

class Add_user_category extends CI_Controller{
    public function __construct(){
        parent::__construct();
        $this->load->model('user_model');
    }
    public function create(){
        $this->form_validation->set_rules(array(array(
                    'field' => 'user_category_name', 
                    'label' => 'user category name', 
                    'rules' => 'trim|required'
                    )));
        if ($this->form_validation->run() == FALSE)	 {        
             $data['main_content']='add_user_category';          
             $this->load->view('ship_template',$data); 
		}else  
        {
            $input_data['user_category_name']=$this->input->post('user_category_name')  ;           
            $input_data['category_description']=$this->input->post('category_description')  ;
                        
            $this->user_model->create_user_category($input_data);
             
             $this->list_user_category();
        } 
    }
    public function list_user_category(){
        $this->session->set_userdata('navigation','List User Category');
        $cond['user_category_deleted']=0;
        $data['user_category_list']=$this->user_model->get_user_category($cond)->result();
        
        if( count($data['user_category_list']) >0){
            $data['main_content']='list_user_category';            
        }else{
           $data['page_title']='User Category Listing';
            $data['main_content']='no_records';            
        }
        $this->load->view('ship_template',$data);
    }
} 
?>